package net.girisha.androidbasics;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.*;
import android.widget.TextView;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.*;

public class TCPClientActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    public void onClickConnect(View view)
    {
    	
    }
    
    @Override
    protected void onStart()
    {
    	super.onStart();
    	
    	WifiManager manager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
    	    	
    	ConnectivityManager conMan = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
    	NetworkInfo networkInfo = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    	
    	WifiInfo wifiInfo = manager.getConnectionInfo();
    	
    	TextView textviewConnectionStatus = (TextView)this.findViewById(R.id.textViewConnectionStatus);
    	TextView textViewConnetedEssid = (TextView)this.findViewById(R.id.textViewConnetedEssid);
    	
    	if(manager.isWifiEnabled())
    	 	if(networkInfo.isConnected())
    	 	{
    	 		textviewConnectionStatus.setText("Connected");
    	 		textViewConnetedEssid.setText(wifiInfo.getSSID());
    	 	}
    	 	else
    	 	{
    	 		textviewConnectionStatus.setText("Not Connected");
    	 		textViewConnetedEssid.setText("Not Applicable");
    	 	}
    		
    		
    	else
    	{
    		textviewConnectionStatus.setText("Not Applicable");
    		textViewConnetedEssid.setText("Not Applicable");
    	}
    }
    
    
    @Override
    public void onStop()
    {
    	super.onStop();
    	
    }
}